﻿namespace UnityEditor
{
    using System;
    using UnityEditorInternal;

    [CustomEditor(typeof(AvatarBodyMask))]
    internal class AvatarBodyMaskInspector : Editor
    {
        protected bool[] m_BodyPartToggle;

        private void OnEnable()
        {
            AvatarBodyMask target = base.target as AvatarBodyMask;
            this.m_BodyPartToggle = new bool[target.GetBodyPartCount()];
        }

        public override void OnInspectorGUI()
        {
            AvatarBodyMask target = base.target as AvatarBodyMask;
            for (int i = 0; i < target.GetBodyPartCount(); i++)
            {
                this.m_BodyPartToggle[i] = target.GetBodyPart(i);
            }
            this.m_BodyPartToggle = BodyMaskEditor.Show(this.m_BodyPartToggle, target.GetBodyPartCount());
            bool flag = false;
            for (int j = 0; j < target.GetBodyPartCount(); j++)
            {
                flag |= target.GetBodyPart(j) != this.m_BodyPartToggle[j];
            }
            if (flag)
            {
                Undo.RegisterUndo(target, "Body Mask Edit");
                for (int k = 0; k < target.GetBodyPartCount(); k++)
                {
                    target.SetBodyPart(k, this.m_BodyPartToggle[k]);
                }
                EditorUtility.SetDirty(target);
            }
        }
    }
}

